package com.xbongbong.paas.model.impl;

import com.xbongbong.paas.domain.dao.PaasCoUserDao;
import com.xbongbong.paas.domain.entity.PaasCoUserEntity;
import com.xbongbong.paas.model.PaasCoUserModel;
import com.xbongbong.paas.toolbox.util.DateUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author: wufeng
 * @date: 2018/8/13 15:22
 * @desrcption: PaaS流程设计实现类
 */
@Service("paasCoUserModel")
public class PaasCoUserModelImpl implements PaasCoUserModel {

    private static final String COLUMNS = " id, corpid, app_id, form_id, form_data_id, co_user_id, add_time, update_time, del ";


    @Resource
    private PaasCoUserDao paasCoUserDao;

    @Override
    public Integer insert(PaasCoUserEntity entity) {
        long now = DateUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        return paasCoUserDao.insert(entity);
    }

    @Override
    public void insertBatch(List<PaasCoUserEntity> paasCoUserList) {
        paasCoUserDao.insertBatch(paasCoUserList);
    }

    @Override
    public List<PaasCoUserEntity> list(Map<String, Object> map) {
        map.put("columns", new StringBuffer(COLUMNS));
        return paasCoUserDao.findEntitys(map);
    }

    @Override
    public PaasCoUserEntity getByKey(Integer key, String corpid) {

        return paasCoUserDao.getByKey(key, corpid);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> map) {
        return paasCoUserDao.getEntitysCount(map);
    }

    @Override
    public Integer delete(Integer key, String corpid) {
        return  paasCoUserDao.deleteByKey(key, corpid);
    }

    @Override
    public Integer update(PaasCoUserEntity entity) {
        long now = DateUtil.getInt();
        entity.setUpdateTime(now);
        return paasCoUserDao.update(entity);
    }

}
